package cn.yl.caner.dao;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;

import cn.yl.caner.domain.AddData;
import cn.yl.caner.utils.DataSourceUtils;
import cn.yl.caner.utils.MyDataSourceUtils;

public class AddDao {
	
	public int addAccount(AddData adddata) throws SQLException  {
		//这个是查询账号信息的DAO层；
		int i = 0;
		Connection con = MyDataSourceUtils.getCurrentConnection();
		DataSource source = DataSourceUtils.getDataSource();
		QueryRunner q = new QueryRunner(source);
		System.out.println(adddata.toString());
		String sql = "update account set birthday_year = ?,birthday_month = ?,birthday_day = ?,sex= ?,self = ? ,age = ? where username = ?";
		 i  = q.update(con,sql,adddata.getAdd_birthday_year(),adddata.getAdd_birthday_month(),
				 adddata.getAdd_birthday_day(),adddata.getAdd_sex(),adddata.getAdd_text(),adddata.getAdd_age(),adddata.getAdd_username());
		 System.out.println(i);
		 return  i;
	}
	
	
	
}
